/***********************************************************************
 * POJO Class :  SysRole.java
 * Author:  Bill Vison
 * Purpose: Defines the Class SysRole
 ***********************************************************************/

package org.vsg.security.model.domain;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;

@javax.persistence.Entity
@javax.persistence.Table(name = "sys_role")
public class SysRole implements java.io.Serializable,java.lang.Cloneable {


	@Column(name ="id")
	@Id
	@GeneratedValue(strategy = javax.persistence.GenerationType.IDENTITY)			

	protected int id;
	 
	
	protected String code;
	 
	
	protected String name;
	 
	
	protected String description;
	 
	@Column(name ="CREATED_DATE")
	private java.sql.Timestamp createdDate;
	 
	@Column(name ="FLAG_INACTIVE")
	private short flagInactive;
	 
	@Column(name ="FLAG_DELETED")
	private short flagDeleted;
	 
	@OneToMany( cascade = {javax.persistence.CascadeType.ALL})
	@JoinTable(
		name="role_hierarchy",
		joinColumns = @JoinColumn( name="id_role_inheritance"),
		inverseJoinColumns = @JoinColumn( name="id_role_dependence")
	)	
	private Set<SysRole> dependenceRoles = new HashSet<SysRole>();
	
	@OneToMany( cascade = {CascadeType.ALL})
	@JoinTable(
		name="map_role_ssd",
		joinColumns = @JoinColumn( name="base_sys_role"),
		inverseJoinColumns = @JoinColumn( name="sdd_sys_role")
	)
	private Set<SysRole> conflictRoles = new HashSet<SysRole>();
	
	@OneToMany(
	mappedBy="role",
	cascade = {javax.persistence.CascadeType.ALL},
	fetch = javax.persistence.FetchType.LAZY)	
	private java.util.Set<ResourceAssociation> assignedPermissions = new HashSet<ResourceAssociation>();
	 
	@javax.persistence.ManyToMany(
   		cascade = {javax.persistence.CascadeType.PERSIST, javax.persistence.CascadeType.MERGE},
    	mappedBy = "assignedRoles",
    	targetEntity = SysActor.class,
    	fetch = javax.persistence.FetchType.LAZY
	)
	private java.util.Set<SysActor> associatedActors = new HashSet<SysActor>();
	 


	
	/**
	 * @param newId
	 */	
	public void setId(int newId) {
		id = newId;
	}
	
	public int getId() {
		return id;
	}	
	
	/**
	 * @param newCode
	 */	
	public void setCode(String newCode) {
		code = newCode;
	}
	
	public String getCode() {
		return code;
	}	
	
	/**
	 * @param newName
	 */	
	public void setName(String newName) {
		name = newName;
	}
	
	public String getName() {
		return name;
	}	
	
	/**
	 * @param newDescription
	 */	
	public void setDescription(String newDescription) {
		description = newDescription;
	}
	
	public String getDescription() {
		return description;
	}	
	
	/**
	 * @param newCreatedDate
	 */	
	public void setCreatedDate(java.sql.Timestamp newCreatedDate) {
		createdDate = newCreatedDate;
	}
	
	public java.sql.Timestamp getCreatedDate() {
		return createdDate;
	}	
	
	/**
	 * @param newFlagInactive
	 */	
	public void setFlagInactive(short newFlagInactive) {
		flagInactive = newFlagInactive;
	}
	
	public short getFlagInactive() {
		return flagInactive;
	}	
	
	/**
	 * @param newFlagDeleted
	 */	
	public void setFlagDeleted(short newFlagDeleted) {
		flagDeleted = newFlagDeleted;
	}
	
	public short getFlagDeleted() {
		return flagDeleted;
	}	
	
	/**
	 * @param newDependenceRoles
	 */	
	public void setDependenceRoles(java.util.Set<SysRole> newDependenceRoles) {
		dependenceRoles = newDependenceRoles;
	}
	
	public java.util.Set<SysRole> getDependenceRoles() {
		return dependenceRoles;
	}	
	
	/**
	 * @param newAssignedPermissions
	 */	
	public void setAssignedPermissions(java.util.Set<ResourceAssociation> newAssignedPermissions) {
		assignedPermissions = newAssignedPermissions;
	}
	
	public java.util.Set<ResourceAssociation> getAssignedPermissions() {
		return assignedPermissions;
	}	
	
	/**
	 * @param newAssociatedActors
	 */	
	public void setAssociatedActors(Set<SysActor> newAssociatedActors) {
		associatedActors = newAssociatedActors;
	}
	
	public Set<SysActor> getAssociatedActors() {
		return associatedActors;
	}

	public Set<SysRole> getConflictRoles() {
		return conflictRoles;
	}

	public void setConflictRoles(Set<SysRole> conflictRoles) {
		this.conflictRoles = conflictRoles;
	}	

	
	
}